{% extends 'wxchat/wxbase.html' %}{% load static %}
{% block extra %}
    <style>
    .weui-select{
        height: 1.47058824em;
        line-height: 1.47058824;
    }
    </style>
{% endblock extra%}
{% block container %}
<div class="weui-panel">
    <div class="weui-panel__hd header_bottom">
         <div class="weui-flex">
            <div><a href="javascript:window.history.back(-1)"><i class="icon iconfont icon-jiantou3 gray " ></i></a></div>
            <div class="weui-flex__item" style="text-align: center;"><span class="detail_title">寄养续费</span></div>
            <div ><a href="{% url 'dog-index' %}?next={{ request.get_full_path }}"><i class="icon iconfont icon-shouye2 pink r" ></i></a></div>
        </div>
    </div>
    <div class="weui-panel__bd">
        <form  action="{% url 'foster-style-calc' %}" method="post" enctype="multipart/form-data" onsubmit="return checkValue();">{% csrf_token %}
        <div class="weui-cells weui-cells_form weui-cells_checkbox cells_top" >
            <div style="display:none">
                <input type="number" name="id" value="{{ form.instance.id|default:""}}" >
                <input type="number" name="big_dog" value="{{ form.big_dog.value|default:0}}" >
                <input type="number" name="middle_dog" value="{{ form.middle_dog.value|default:0}}" >
                <input type="number" name="small_dog" value="{{ form.small_dog.value|default:0}}">
                <input type="number" name="foster_type" value="{{ form.foster_type.value }}">
                <input type="number" name="foster_mode" value="{{ form.foster_mode.value }}">
                <input type="text" name="petlist" value="{{ form.pet_list.value }}">
            </div>

            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">{{ form.begin_time.label }}:</label></div>
                <div class="weui-cell__bd">{{ form.begin_time }}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">{{ form.end_time.label }}:</label></div>
                <div class="weui-cell__bd">{{ form.end_time }}</div>
            </div>
          </div>
        <div class="weui-btn-area">
            <button type="submit" name="submit" id="btn_submit" class="weui-btn weui-btn_primary" >提交</button>
        </div>
        </form>
    </div>
</div>

{% endblock container %}
{% block bottomjs %}
     {{ block.super }}
    <script>
    $(function() {

        $("#id_end_time").on("change", function (event) {
            var endDate = event.target.value;
            var beginDate = $("#id_begin_time").val();

            if (beginDate.length == 0 || endDate.length == 0) return;
            if (beginDate.length > 0 && endDate < beginDate) {
                weui.alert("结束时间不能小于开始时间");
                $("#id_end_time").focus();
            }

        });
    })

    function checkValue(){

       var end_time = $("#id_end_time").val();
       var begin_time = $("#id_begin_time").val();
        if( end_time < begin_time ){
           weui.alert("结束时间不能小于开始时间");
           $("#id_end_time").focus();
           return false
       }
       showing();
    }

    </script>
{% endblock bottomjs %}
